package com.lorenzogao.pley.common.exception

import android.content.Context
import com.lorenzogao.pley.R

/**
 * 作者：Lorenzo Gao
 * Date: 2018/1/2
 * Time: 10:38
 * 邮箱：2508719070@qq.com
 * Description:
 */

class ErrorMessageFactory {

    companion object {
        fun create(context: Context, code: Int): String {
            var errorMsg: String = context.resources.getString(R.string.error_unkown)

            when (code) {
                BaseException.HTTP_ERROR -> errorMsg = context.resources.getString(R.string.error_http)
                BaseException.SCOKET_ERROR -> errorMsg = context.resources.getString(R.string.error_socket_timeout)
                BaseException.SCOKET_ERROR -> errorMsg = context.resources.getString(R.string.error_http)
                BaseException.error_http_400 -> errorMsg = context.resources.getString(R.string.error_http_400)
                BaseException.error_http_404 -> errorMsg = context.resources.getString(R.string.error_http_404)
                BaseException.error_http_500 -> errorMsg = context.resources.getString(R.string.error_http_500)
                BaseException.ERROR_API_SYSTEM -> errorMsg = context.resources.getString(R.string.error_system)
                BaseException.ERROR_API_ACCOUNT_FREEZE -> errorMsg = context.resources.getString(R.string.error_account_freeze)
                BaseException.ERROR_API_NO_PERMISSION -> errorMsg = context.resources.getString(R.string.error_api_no_perission)
                BaseException.ERROR_API_LOGIN -> errorMsg = context.resources.getString(R.string.error_login)
                BaseException.ERROR_TOKEN -> errorMsg = context.resources.getString(R.string.error_token)
                BaseException.ERROR_PARAMS -> errorMsg = context.resources.getString(R.string.error_params)

            }


            return errorMsg!!
        }
    }
}
